package ownserver;

import java.io.Serializable;

import com.sun.sgs.app.AppContext;
import com.sun.sgs.app.DataManager;
import com.sun.sgs.app.ManagedObject;
import com.sun.sgs.app.ManagedReference;
import com.sun.sgs.app.util.ScalableList;

public class Commander implements Serializable, ManagedObject {
	private static final long serialVersionUID = 1L;

	/** The prefix for player bindings in the {@code DataManager}. */
    protected static final String PLAYER_BIND_PREFIX = "Player.";
	
	protected ManagedReference<World> worldRef;
	
	protected int userid;
	
	protected String name;
    
    protected ManagedReference<ScalableList<ServerShip>> ownedShipsRef = null;
    
    public Commander(String n, ManagedReference<World> worldRef, int id) {
        name = n;
        this.worldRef = worldRef;
        userid = id;
        
        DataManager dataManager = AppContext.getDataManager();
        dataManager.markForUpdate(this);
        
        ScalableList<ServerShip> ships = new ScalableList<ServerShip>();
        ownedShipsRef = dataManager.createReference(ships);
    }

    /**
     * Returns the name of this object.
     *
     * @return the name of this object
     */
    public String getName() {
        return name;
    }

    public int getID()
    {
    	return userid;
    }
}
